package net.neptech.controller;


import lombok.RequiredArgsConstructor;
import net.neptech.model.workflow.WorkflowGroup;
import net.neptech.service.GroupService;

import net.neptech.vm.ResponseResult;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 流程组接口
 */
@RestController
@RequestMapping(value = {"processGroup"})
@RequiredArgsConstructor
public class GroupController {
    private final GroupService processGroupService;

    /**
     * 组列表
     */
    @GetMapping("list")
    public ResponseResult<List<WorkflowGroup>> queryList() {
        return ResponseResult.success(processGroupService.queryList());
    }

    /**
     * 新增流程分组
     *
     * @param processGroup 分组名
     * @return 添加结果
     */
    @PostMapping("create")
    public ResponseResult<Void> create(@RequestBody WorkflowGroup processGroup) {
        processGroupService.create(processGroup);
        return ResponseResult.success();
    }
    /**
     * 上移排序
     *
     * @param processGroup 分组名
     * @return 添加结果
     */

    @PostMapping("topSort")
    public ResponseResult<Void> topSort(@RequestBody WorkflowGroup processGroup) {
        processGroupService.topSort(processGroup);
        return ResponseResult.success();
    }
    /**
     * 下移排序
     *
     * @param processGroup 分组名
     * @return 添加结果
     */
    @PostMapping("bottomSort")
    public ResponseResult<Void> bottomSort(@RequestBody WorkflowGroup processGroup) {
        processGroupService.bottomSort(processGroup);
        return ResponseResult.success();
    }

    /**
     * 修改流程分组
     *
     * @param processGroup 分组名
     * @return 添加结果
     */
    @PostMapping("edit")
    public ResponseResult<Void> edit(@RequestBody WorkflowGroup processGroup) {
        processGroupService.edit(processGroup);
        return ResponseResult.success();
    }


    /**
     *  删除分组
     * @param id
     * @return
     */

    @DeleteMapping("delete/{id}")
    public ResponseResult<Void> delete(@PathVariable long id){
        processGroupService.delete(id);
        return ResponseResult.success();
    }
}
